﻿using FigureDraw.Diagram;
using FigureDraw.Graphic;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FigureDraw.Shapes.FlowchartShape
{
    public class MoveFlowchart : MyShape
    {
        public MoveFlowchart()
            : base()
        {
        }

        public MoveFlowchart(MyPoint startPoint, MyPoint endPoint)
            : base(startPoint, endPoint)
        {
            
        }

        public override void Draw(CommonGraphic graphic)
        {
            double arrowDegrees = 0.5;
            double arrowLength = 15;

            double angle = Math.Atan2(endPoint.Y - startPoint.Y, endPoint.X - startPoint.X) + Math.PI;

            double arrowX1 = endPoint.X + arrowLength * Math.Cos(angle - arrowDegrees);
            double arrowY1 = endPoint.Y + arrowLength * Math.Sin(angle - arrowDegrees);
            double arrowX2 = endPoint.X + arrowLength * Math.Cos(angle + arrowDegrees);
            double arrowY2 = endPoint.Y + arrowLength * Math.Sin(angle + arrowDegrees);

            graphic.DrawLine(startPoint, endPoint, strokeColor, strokeWidth);
            graphic.DrawLine(new MyPoint(arrowX1, arrowY1), endPoint, strokeColor, strokeWidth);
            graphic.DrawLine(new MyPoint(arrowX2, arrowY2), endPoint, strokeColor, strokeWidth);
        }

        public override MyShape Clone(BlockDiagram diagram)
        {
            MyShape shape = diagram.DrawMove(startPoint, endPoint);
            shape.StrokeColor = strokeColor;
            shape.StrokeWidth = strokeWidth;
            shape.BrushColor = brushColor;

            return shape; 
        }

        public override MyShape Clone()
        {
            MyShape shape = new MoveFlowchart(startPoint, endPoint);
 
            shape.StrokeColor = strokeColor;
            shape.StrokeWidth = strokeWidth;
            shape.BrushColor = brushColor;

            return shape;

            
        }
    }
}
